import time

from selenium.webdriver.common.by import By
from Base.Base import Base

class Page(Base):
    login=(By.LINK_TEXT,'登录')
    log=(By.XPATH,'/html/body/div[4]/div/div[1]/div[1]/span[1]')
    name=(By.NAME,'username')
    pwd=(By.NAME,'password')
    dl=(By.XPATH,'/html/body/div[4]/div/div[1]/div[2]/form/div[5]/a')
    hui=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    yu_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]/span')

    def yu(self):
        return self.text(self.yu_loc)
    def login_cl(self):
        self.click(self.login)
    def send_name(self):
        self.send_keys(self.name,'17800382574')
    def send_pwd(self):
        self.send_keys(self.pwd,'123456')
    def dl_cl(self):
        self.click(self.dl)
    def dy1(self):
        return self.text(self.log)
    def dy2(self):
        return self.text(self.hui)


    def luoji_01_login(self):
        self.open_url('http://10.59.9.12:7001/')
        self.login_cl()
        print(self.dy1())
        self.send_name()
        self.send_pwd()
        # 强制等待输入验证码
        time.sleep(10)
        self.dl_cl()
        time.sleep(5)
        print(self.dy2())
